﻿<Page
    x:Class="NetworkInfoExample.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:NetworkInfoExample"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:common="using:NetworkInfoExample.Common"
    xmlns:data="using:NetworkInfoExample.Data"
    mc:Ignorable="d">
    <Page.Resources>
        <common:BitsConverter x:Key="ShowBits"/>
        <common:BytesConverter x:Key="ShowBytes"/>
        <common:SignalConverter x:Key="ShowSignal"/>
        <common:BooleanVisibilityConverter x:Key="ShowVisible"/>
    </Page.Resources>
    <Grid x:Name="RootGrid" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" d:DataContext="{d:DesignInstance Type=data:ViewModel, IsDesignTimeCreatable=True}">
        <Grid.ChildrenTransitions>
            <TransitionCollection>
                <EntranceThemeTransition/>
            </TransitionCollection>
        </Grid.ChildrenTransitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="140"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid Grid.Row="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="120"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Button Margin="39,59,39,0"
                        Style="{StaticResource NavigationBackButtonNormalStyle}"
                        VerticalAlignment="Top"
                        Visibility="Collapsed"/>
            <TextBlock Text="Network Information" Style="{StaticResource HeaderTextBlockStyle}" Grid.Column="1" 
                        IsHitTestVisible="false" TextWrapping="NoWrap" VerticalAlignment="Bottom" Margin="0,0,30,40"/>
        </Grid>
        <Grid Grid.Row="1">
            <ListView Grid.Column="0" 
                      x:Name="Connections" 
                      ItemsSource="{Binding Path=ConnectionProfiles}"
                      SelectedItem="{Binding Path=CurrentConnectionInfo, Mode=TwoWay}">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <Grid Margin="10" DataContext="{Binding}">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <ContentControl Grid.Row="0" VerticalAlignment="Center" Content="{Binding Path=SignalBars, Converter={StaticResource ShowSignal}}"/>
                            <StackPanel Grid.Row="0" Margin="30 0 0 0">
                                <TextBlock Text="{Binding Path=Name}" Style="{StaticResource SubheaderTextBlockStyle}"/>
                                <TextBlock Text="{Binding Path=NetworkAdapterId}"/>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Grid.Row="1">
                                <TextBlock Text="WLAN" Visibility="{Binding IsWlan, Converter={StaticResource ShowVisible}}"/>
                                <TextBlock Text="WWAN" Margin="10 0 0 0" Visibility="{Binding IsWwan, Converter={StaticResource ShowVisible}}"/>
                                <TextBlock Text="Max Rates:" Margin="10 0 0 0"/>
                                <TextBlock Text="{Binding IncomingBitsPerSecond, Converter={StaticResource ShowBits}}" Margin="10 0 0 0"/>
                                <TextBlock Text="/"/>
                                <TextBlock Text="{Binding OutgoingBitsPerSecond, Converter={StaticResource ShowBits}}"/>                                
                                <TextBlock Text="24 Hour Usage (sent/received):" Margin="10 0 0 0"/>
                                <TextBlock Text="{Binding BytesSentLastDay, Converter={StaticResource ShowBytes}}" Margin="10 0 0 0"/>
                                <TextBlock Text="/"/>
                                <TextBlock Text="{Binding BytesReceivedLastDay, Converter={StaticResource ShowBytes}}"/>

                            </StackPanel>
                           <StackPanel Orientation="Horizontal" Grid.Row="2">
                               <SymbolIcon Symbol="Permissions"/> 
                               <TextBlock Text="Authentication: "/>
                                <TextBlock Text="{Binding AuthenticationType}" Margin="10 0 0 0"/>
                                <SymbolIcon Symbol="ProtectedDocument" Margin="10 0 0 0"/>
                                <TextBlock Text="Encryption: "/>
                                <TextBlock Margin="10 0 0 0" Text="{Binding EncryptionType}"/>                                
                            </StackPanel>
                            <StackPanel Grid.Row="3" Orientation="Horizontal">
                                <TextBlock Text="Connection:"/>
                                <TextBlock Text="{Binding ConnectivityLevel}" Margin="10 0 0 0"/>
                                <TextBlock Text="Domain:" Margin="10 0 0 0"/>
                                <TextBlock Text="{Binding DomainConnectivityLevel}" Margin="10 0 0 0"/>
                                <TextBlock Text="Status Flags:" Margin="10 0 0 0"/>
                                <TextBlock Text="{Binding Flags}" Margin="10 0 0 0"/>
                            </StackPanel>
                            <StackPanel Grid.Row="4" Orientation="Vertical" Visibility="{Binding HasDataPlan, Converter={StaticResource ShowVisible}}">
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="Data Plan: Usage (Megabytes)"/>
                                    <TextBlock Text="{Binding DataPlan.MegabytesUsed}" Margin="10 0 0 0"/>
                                    <StackPanel Orientation="Horizontal" Visibility="{Binding DataPlan.LastSyncTime.HasValue, Converter={StaticResource ShowVisible}}">
                                        <TextBlock Text="Last Sync:" Margin="10 0 0 0"/>
                                        <TextBlock Text="{Binding DataPlan.LastSyncTime}" Margin="10 0 0 0"/>
                                    </StackPanel>
                                </StackPanel>
                                <StackPanel Orientation="Horizontal" Margin="30 0 0 0">
                                    <TextBlock Text="Speed:"/>
                                    <TextBlock Text="{Binding DataPlan.InboundBitsPerSecond, Converter={StaticResource ShowBits}}" Margin="10 0 0 0"/>
                                    <TextBlock Text="/"/>
                                    <TextBlock Text="{Binding DataPlan.OutboundBitsPerSecond, Converter={StaticResource ShowBits}}"/>
                                    <TextBlock Text="Limit (Magabytes):" Margin="10 0 0 0"/>
                                    <TextBlock Text="{Binding DataPlan.DataLimitMegabytes}" Margin="10 0 0 0"/>
                                    <StackPanel Orientation="Horizontal" Visibility="{Binding DataPlan.NextBillingCycle.HasValue, Converter={StaticResource ShowVisible}}">
                                        <TextBlock Text="Next Bill:" Margin="10 0 0 0"/>
                                        <TextBlock Text="{Binding DataPlan.NextBillingCycle}" Margin="10 0 0 0"/>
                                    </StackPanel>
                                </StackPanel>
                            </StackPanel>
                        </Grid>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>            
        </Grid>        
    </Grid>
</Page>
